/**
 * Created by huotaol on 2017/5/10.
 */
import React, {Component} from "react";
import {ListView, StyleSheet, Text, View} from "react-native";
import CustomStyle from "../../../common/style/CustomStyle";
import {connect} from "react-redux";

const DATA_SOURCE = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});


class OrderSoldCarUI extends Component {

    // 构造
    constructor(props) {
        super(props);
        // 初始状态
        this.state = {data: []};
        this._renderItem = this._renderItem.bind(this);
    }

    componentDidMount() {
        this.setState({data: []});
    }

    render() {
        return (
            <View style={{flex: 1}}>
                <ListView
                    style={[this.props.style,]}
                    dataSource={DATA_SOURCE.cloneWithRows(this.state.data)}
                    renderRow={this._renderItem}
                    renderSeparator={this._renderSeparator}
                />
            </View>
        );
    }

    _renderItem(item) {
        return <View >
            <Text style={[CustomStyle.baseText, {
                fontSize: CustomStyle.getActualFontSize(15),
                color: 'black',
            }]}>{item.phone}</Text>
            <Text style={[CustomStyle.baseText, {
                fontSize: CustomStyle.getActualFontSize(15),
                color: 'black',
            }]}>{item.detail}</Text>
            <Text style={[CustomStyle.baseText, {
                fontSize: CustomStyle.getActualFontSize(15),
                color: 'black',
            }]}>{item.date}</Text>
            <Text style={[CustomStyle.baseText, {
                fontSize: CustomStyle.getActualFontSize(15),
                color: 'black',
            }]}>{item.area}</Text>
        </View>;
    }

    _renderSeparator() {
        return <View
            style={{height: StyleSheet.hairlineWidth, flex: 1, backgroundColor: 'rgba(0,0,0,0.2)'}}/>
    }

}

export default connect()(OrderSoldCarUI);